<?php
declare(strict_types = 1);
namespace app\admin\middleware;

use think\facade\Session;

class Auth
{
    /**
     *
     * @param $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle($request, \Closure $next)
    {
////        print_r(!preg_match("/captcha/", $request->pathinfo()));exit;
//        if (!preg_match("/login/", $request->pathinfo()) && !preg_match("/captcha/", $request->pathinfo())) {
//            echo 'xxx';exit;
////            return redirect((string)url('login/index'));
//        }
//        //前置中间件
//        if (!Session::has(config('admin.session_admin'))) {
//            if (!preg_match("/login/", $request->pathinfo()) && !preg_match("/captcha/", $request->pathinfo())) {
//                return redirect((string)url('login/index'));
//            }
//        }

        //后置中间件
        $response =  $next($request);


        return $response;
    }

    /**
     * 中间件结束调度
     * @param \think\Response $response
     */
    public function end(\think\Response $response)
    {

    }
}